/*
 * @Description:
 * @Author: maskMan
 * @LastEditTime: 2024-06-11 20:25:20
 */
import request from '@/utils/request'
import { IArticleData, IGameInfo, IUserInfo } from './types'

export const defaultArticleData: IArticleData = {
  id: 0,
  status: 'draft',
  title: '',
  fullContent: '',
  abstractContent: '',
  sourceURL: '',
  imageURL: '',
  timestamp: '',
  platforms: ['a-platform'],
  disableComment: false,
  importance: 0,
  author: '',
  reviewer: '',
  type: '',
  pageviews: 0
}
export const defaultUserData: IUserInfo = {
  id: 0,
  status: '正常',
  account: '',
  commit: '',
  password: '',
  createTime: '',
  endTime: '',
  level: '一级会员'
}
export const defaultGameData: IGameInfo = {
  id: 0,
  gameId: '',
  desc: '',
  gameName: '',
  image: ''
}
export const getArticles = (params: any) =>
  request({
    url: 'admin/getUserList',
    method: 'get',
    params
  })
export const getGameList = (params: any) =>
  request({
    url: 'admin/getGameList',
    method: 'get',
    params
  })
export const getArticle = (id: number, params: any) => {
  request({
    url: `/articles/${id}`,
    method: 'get',
    params
  })
}

export const createArticle = (data: any) =>
  request({
    url: '/articles',
    method: 'post',
    data
  })

export const updateArticle = (id: number, data: any) =>
  request({
    url: `/articles/${id}`,
    method: 'put',
    data
  })

export const deleteArticle = (id: number) =>
  request({
    url: `/articles/${id}`,
    method: 'delete'
  })

export const getPageviews = (params: any) =>
  request({
    url: '/pageviews',
    method: 'get',
    params
  })
